package com.yhy.auth.handler;

import com.yhy.common.security.handler.AbstractAuthenticationSuccessEventHandler;
import com.yhy.common.security.model.MyUser;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.core.Authentication;
import org.springframework.stereotype.Component;

/**
 * @author jax-li
 */
@Slf4j
@Component
public class MyAuthenticationSuccessEventHandler extends AbstractAuthenticationSuccessEventHandler {

    /**
     * 处理登录成功方法
     * <p>
     * 获取到登录的authentication 对象
     */
    public void handle(Authentication authentication) {
        Object principal = authentication.getPrincipal();
        if (principal instanceof MyUser) {
            authentication.getDetails();
        }
        log.info("认证成功 : {}", authentication.getName());
    }

}